package com.lagou.course.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.lagou.course.CourseService;
import com.lagou.entity.Course;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 课程控制层
 *
 * @author huangshuxian
 */
@RestController
@RequestMapping("course")
public class CourseController {

    @Reference//远程消费
    private CourseService courseService;

    @GetMapping("getAllCourse")
    public List<Course> getAllCourse() {
        List<Course> list = courseService.getAllCourse();
        return list;
    }

    @GetMapping("getCourseByUserId/{userId}")
    public List<Course> getCourseByUserId( @PathVariable("userId") String userId ) {
        List<Course> list = courseService.getCourseByUserId(userId);
        return list;
    }

    @GetMapping("getCourseById/{courseId}")
    public Course getCourseById(@PathVariable("courseId")Integer courseId) {
        Course course = courseService.getCourseById(courseId);
        return course;
    }
}
